package qdu.my.ch1_intent_path;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.BackgroundColorSpan;
import android.text.style.UnderlineSpan;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
    Button btn_nopath, btn_go1, btn_go2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        btn_nopath = (Button) findViewById(R.id.btn_nopath);
        btn_go1 = (Button) findViewById(R.id.btn_to1st);
        btn_go2 = (Button) findViewById(R.id.btn_to2nd);
        
        btn_nopath.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent("myaction", Uri.parse("myqdu://qdu.dataschool:8888")));
			}
		});
        
        btn_go1.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent("myaction", Uri.parse("myqdu://qdu.dataschool:8888/class1?message=this is class1")));
			}
		});
        
        btn_go2.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent("myaction", Uri.parse("myqdu://qdu.dataschool:8888/class2?message=this is class2")));
			}
		});
        //&&&&&&&&&&&&&&&&&&&&multi style in one&&&&&&&&&&&&&&&&&&&&&&&&&&
		String str =this.getString(R.string.sum);
		SpannableString sum_str = new SpannableString(str);
		sum_str.setSpan(new BackgroundColorSpan(Color.parseColor("#200000FF")),str.indexOf("配合"), str.indexOf("，包括"), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        sum_str.setSpan(new UnderlineSpan(),str.indexOf("包括"),str.indexOf("（通过网页"),0);
		sum_str.setSpan(new UnderlineSpan(),str.indexOf("文件关联"),str.indexOf("（通过网络"),0);

		((TextView)findViewById(R.id.tv_sum)).setText(sum_str);
    }
}
